/*
 * Copyright (c) 2009-2013 EvTech Project
 * All rights reserved.
 * 
 * This file is part of Symbol Matching.
 *
 * Symbol Matching is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version.
 *
 * Symbol Matching is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Symbol Matching.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package fi.honkalampisaatio.reaktiopeli.xml;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;


public class GameDifficulty {
	@XmlEnum
	public enum DIFFICULTY{ROUNDS10, ROUNDS20, ROUNDS30, EASY, NORMAL, HARD};
	private final static DIFFICULTY DEFAULT_SPEED = DIFFICULTY.NORMAL;
	@XmlElement(name = "perusaika")
	private DIFFICULTY difficulty;


	public DIFFICULTY getDifficulty() {
		return this.difficulty;
	}
	
	public void setDifficulty(String difficulty) {
		if(difficulty.equalsIgnoreCase(DIFFICULTY.ROUNDS10.toString())) {
			this.difficulty = DIFFICULTY.ROUNDS10;
		}
		else if(difficulty.equalsIgnoreCase(DIFFICULTY.ROUNDS20.toString())) {
			this.difficulty = DIFFICULTY.ROUNDS20;
		}
		else if(difficulty.equalsIgnoreCase(DIFFICULTY.ROUNDS30.toString())) {
			this.difficulty = DIFFICULTY.ROUNDS30;
		}
		else if(difficulty.equalsIgnoreCase(DIFFICULTY.EASY.toString())) {
			this.difficulty = DIFFICULTY.EASY;
		}
		else if(difficulty.equalsIgnoreCase(DIFFICULTY.NORMAL.toString())) {
			this.difficulty = DIFFICULTY.NORMAL;
		}
		else if(difficulty.equalsIgnoreCase(DIFFICULTY.HARD.toString())) {
			this.difficulty = DIFFICULTY.HARD;
		}
		else {
			this.difficulty = DEFAULT_SPEED;
		}
	}
	
	public long getRoundTime() {
		if(difficulty==null)
			difficulty = DEFAULT_SPEED;
		switch(difficulty) {
			case EASY:
				return 30000;
			case NORMAL:
				return 15000;
			case HARD:
				return 6000;
			default:
				return 0;
		}
	}
	
	public int getRounds() {
		if(difficulty==null)
			difficulty = DEFAULT_SPEED;
		switch(difficulty) {
			case ROUNDS10:
				return 10;
			case ROUNDS20:
				return 20;
			case ROUNDS30:
				return 30;
			default:
				return 0;
		}
	}
}
